var e = require("../../../@babel/runtime/helpers/defineProperty"), t = require("../../../wxParse/wxParse"), a = getApp();

Page({
    data: {
        timeData: {},
        checked: !1,
        time: 864e5,
        buyingid: 0,
        detailData: {},
        goods: [],
        explainFlag: !1,
        deliver_id: 0,
        shareShow: !1,
        shareOptions: [ {
            name: "生成海报",
            icon: "poster"
        }, {
            name: "分享给好友",
            icon: "wechat",
            openType: "share"
        } ]
    },
    onSelectShare: function(e) {
        this.onCloseShare(), 0 == e.detail.index && this.setData({
            posterShow: !0
        }), console.log(e.detail.index);
    },
    onCloseShare: function() {
        this.setData({
            shareShow: !1
        });
    },
    openShareShow: function() {
        this.setData({
            shareShow: !0
        });
    },
    gotoBuyingOrder: function() {
        wx.navigateTo({
            url: "/packageE/community_buying/buying_order/buying_order?buyingid=" + this.data.buyingid
        });
    },
    gotoBuyingData: function() {
        wx.navigateTo({
            url: "/packageE/community_buying/buying_data/buying_data?buyingid=" + this.data.buyingid
        });
    },
    setExplainFlag: function() {
        this.setData({
            explainFlag: !this.data.explainFlag
        });
    },
    onLoad: function(e) {
        this.setData({
            buyingid: e.buyingid
        }), this.getDetails();
    },
    onChangeTime: function(e) {
        this.setData({
            timeData: e.detail
        });
    },
    onChangeSwitch: function(t) {
        console.log(t);
        var i = t.target.dataset.goods_id, n = "goods[" + t.target.dataset.index + "].checked";
        this.setData(e({}, n, t.detail));
        var o = a.getNetAddresss("plugin.package-deliver.frontend.communityGroups.banGoods");
        a._postNetWork({
            url: o,
            data: {
                group_id: this.data.buyingid,
                goods_id: i
            },
            success: function(e) {
                var t = e.data;
                console.log(t), 1 == t.result && console.log("操作成功");
            }
        });
    },
    onReady: function() {
        var e = wx.getStorageSync("langIndex");
        this.setData({
            language: e.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    getDetails: function() {
        var e = this, i = this, n = a.getNetAddresss("plugin.package-deliver.frontend.communityGroups.groupGoods");
        a._postNetWork({
            url: n,
            data: {
                id: this.data.buyingid
            },
            success: function(a) {
                var n = a.data;
                if (console.log(n), 1 == n.result) {
                    var o = n.data.group, s = 0;
                    0 == o.group_status ? s = new Date(o.start_time.replace(/-/g, "/")).getTime() - new Date().getTime() : 1 == o.group_status && (s = new Date(o.end_time.replace(/-/g, "/")).getTime() - new Date().getTime());
                    var d = o.goods;
                    d.forEach(function(e) {
                        e.checked = 0 != e.status;
                    }), e.setData({
                        deliver_id: n.data.deliver_id,
                        detailData: o,
                        time: s,
                        goods: d
                    });
                    var r = o.description;
                    try {
                        r.indexOf("&#") <= -1 && t.wxParse("article", "html", r, i);
                    } catch (e) {
                        console.log(e);
                    }
                }
            }
        });
    },
    onShareAppMessage: function() {
        var e = wx.getStorageSync("yz_uid"), t = "/packageE/community_buying/buying_personal/buying_personal?buyingid=" + this.data.buyingid + "&deliver_id=" + this.data.deliver_id;
        e && (t = t + "&mid=" + e);
        var a = {
            path: t
        };
        return this.data.detailData.share_img && (a.imageUrl = this.data.detailData.share_img), 
        a;
    }
});